package bgate.hung.activity;

import bgate.hung.workerclass.Player;
import android.app.Activity;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.EditText;

public class Register extends Activity {
	private static final String TAG = "RegisterActivity";
	private String account = "";
	private String passWord = "";
	private EditText accEditText, passEditText, confirmPassEditText;
	private CheckBox maleCheckBox, femaleCheckBox;
	private int sex = Player.MALE;
	private boolean blockCheck = false;

	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
				WindowManager.LayoutParams.FLAG_FULLSCREEN);
		setContentView(R.layout.register_layout);

		accEditText = (EditText) findViewById(R.id.accountEditText_register_layout);
		passEditText = (EditText) findViewById(R.id.passWordEditText_register_layout);
		confirmPassEditText = (EditText) findViewById(R.id.confirmPassEditText_register_layout);
		maleCheckBox = (CheckBox) findViewById(R.id.namCheckBox_register_layout);
		femaleCheckBox = (CheckBox) findViewById(R.id.nuCheckBox_register_layout);

		maleCheckBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {

			public void onCheckedChanged(CompoundButton buttonView,
					boolean isChecked) {
				// TODO Auto-generated method stub
				if (!blockCheck) {
					blockCheck = true;
					if (sex == Player.MALE) {
						sex = Player.FEMALE;
					} else {
						sex = Player.MALE;
					}
					if (sex == Player.MALE) {
						femaleCheckBox.setChecked(false);
					} else if (sex == Player.FEMALE) {
						femaleCheckBox.setChecked(true);
					}
					blockCheck = false;
				}
			}
		});

		femaleCheckBox
				.setOnCheckedChangeListener(new OnCheckedChangeListener() {

					public void onCheckedChanged(CompoundButton buttonView,
							boolean isChecked) {
						// TODO Auto-generated method stub
						if (!blockCheck) {
							blockCheck = true;
							if (sex == Player.FEMALE) {
								sex = Player.MALE;
							} else {
								sex = Player.FEMALE;
							}
							if (sex == Player.MALE) {
								maleCheckBox.setChecked(true);
							} else if (sex == Player.FEMALE) {
								maleCheckBox.setChecked(false);
							}
							blockCheck = false;
						}
					}
				});
	}
}
